#ifndef _Tools_
#define _Tools_
#include <Windows.h>
#include <new>
#include <d3d9.h>
#include <time.h> 
#include <fstream>
#define MASKVALUE   0x12345678
#define KEYVALUE	0x13

typedef int (__stdcall MyMessageboxA) (int,char*,char*,int);
typedef int (__stdcall MySleep) (int);
typedef int (__stdcall MyGetModuleFileName) (HMODULE, LPSTR, DWORD);
typedef int (__stdcall MyCreateThread) (LPSECURITY_ATTRIBUTES lpThreadAttributes,SIZE_T dwStackSize,LPTHREAD_START_ROUTINE lpStartAddress,LPVOID lpParameter, DWORD dwCreationFlags,LPDWORD lpThreadId);
typedef int (__stdcall MyLoadLibrary) (LPSTR);
typedef int (__stdcall MyVirtualProtect) (LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
typedef int (__stdcall MyMemSet)(void * _Dst, int _Val,  size_t _Size);
typedef HMODULE (__stdcall MyGetModuleHandle)(LPCSTR ModuleName);

extern MyMessageboxA *MsgBox;
extern MySleep *pSleep;
extern MyGetModuleFileName *pGetModuleFileName;
extern MyCreateThread *pCreateThread;
extern MyLoadLibrary *pLoadLibrary;
extern MyVirtualProtect *pVirtualProtect;
extern MyGetModuleHandle *pGetModuleHandle;

class cTools{
public:
	VOID MemPatch(PUCHAR dest, CONST PUCHAR src, INT len);
	VOID MemSet(PBYTE dest, INT val, INT len);
	VOID DirectMemAlloc(PUCHAR dest, INT len);
	VOID MemXorJmp(DWORD adr, DWORD cavefunc);
	DWORD MemHotPatch(DWORD adr, DWORD caveadr, bool dip_activate , bool r = 0);
	bool bCompare(CONST PBYTE pData, CONST PBYTE bMask, CONST PCHAR szMask);
	DWORD FindPattern(DWORD dwAddress, DWORD dwLen, PBYTE bMask,PCHAR szMask);
	DWORD** FindDevice(VOID);
	DWORD FindAPI(CONST PCHAR DLLName, CONST PCHAR FunctionName);
	VOID add_log (CONST PCHAR fmt, ...);
	VOID XorStr(char* str, int key = KEYVALUE);
	char* WINAPI GetFrameRate();
	HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32);

	cTools( VOID ){ memset(dllfn, 0, 301); memset(logfn, 0, 301); }
	CHAR dllfn[301];	
	CHAR logfn[301];
private:
	PUCHAR DirectMemAllocMemPtr;

};
#endif _Tools_